package edu.tsinghua.ddb.sandbox;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.rmi.ConnectException;

import edu.tsinghua.ddb.main.console.MyLog;
import edu.tsinghua.ddb.site.Site;
import edu.tsinghua.ddb.site.SitePool;
import edu.tsinghua.ddb.util.TicToc;

public class SpeedTest {
	public static void delivery(){
		// exe as demo 
		// only can send from site1 to site2!!!!!
		
		try {
			Site site2 = SitePool.get("site2");
			TicToc.tic();
			site2.upload(getGD(), "site2.rar");
			MyLog.debug(TicToc.toc());
		} catch (ConnectException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	private static byte[] getGD() throws Exception {
		File f=new File("c:\\pack\\must\\SymantecAntivirus10.rar");
		FileInputStream fis=new FileInputStream(f);
		int l=(int)f.length();
		byte[] bs=new byte[l];
		fis.read(bs);
		System.out.println(bs[l/2]);
		fis.close();
		return bs;
	} 
}
